<?php
if(isset($_SESSION['roles']) && isset($_SESSION['sess_login_username'])){
    if( ($_SESSION['sess_login_username']!='') && ($_SESSION['roles']!='')){

    }
    else
        header('Location: index.php');

}
else
        header('Location: index.php');
require('./roots.php');

require_once('./classes/rbac.php');

include('languaje/'.$_SESSION['lang'].'/lang_'.$_SESSION['lang'].'_rbac.php');

include "header.php";

$action='AsignacionActivarDesactivar.php';

$msj = '';

$rbac= new rbac();

if (isset($_GET['id_role']) && isset($_GET['id_user']) && isset($_GET['s'])){
    $role=$_GET['id_role'];
    $user=$_GET['id_user'];
    $status=$_GET['s'];
    if ($status==1){
        $result=$rbac->Desactivar_rol_usuario($role,$user,$_SESSION['sess_login_username']);
	//var_dump($status);
    }else if($status==0){
        $result=$rbac->Activar_rol_usuario($role,$user,$_SESSION['sess_login_username']);
	//var_dump($status);
	}
    if ($result==NULL){
        $Message=$LDModiAsigError;
    }
    else if($result==FALSE){
        $Message=$LDNoPermiso;
    }
    else if($result==TRUE){
        $Message=$LDModiAsig;
    }

}
$gui=$rbac->Buscar_rol_usuario(NULL,NULL,$_SESSION['sess_login_username']);

?>


 <form method="post" action="<?php echo $action; ?>" name="regform" ENCTYPE="multipart/form-data" onSubmit="return chkform(this)"> 


	<div id="page">
	<div id="page-bgtop">
	<div id="page-bgbtm">
		<div id="content">
			<div class="post">
			<div class="post-bgtop">
			<div class="post-bgbtm">
				<h2 class="title"><a href="#"><?php echo $LDListaAsignacion; ?></a></h2>
					
				<div class="entry">
					<p>
				<?php echo $Message; ?>

                                        <h2 class="title">
						<table width=100%>
							<tr>
								<td width=40%>
									<a href="#"><?php echo $LDNombre; ?></a>
								</td>
                                                                <td width=40%>
									<a href="#"><?php echo $LDRol; ?></a>
								</td>
								<td width=20%>
									<a href="#"><?php echo $LDEstado; ?></a>
								</td>
								
							</tr>
						</table>
					</h2>
					<?php
                                        if ($gui)
					if($gui!=NULL){
					foreach($gui as $array=>$name){
					?>

                                        <div class="table">
                                                <table width=100%>
							<tr>
								<td width=40%>
                                                                        <?php echo $name['id_user']; ?>

								</td>
                                                                <td width=40%>
									<?php echo $name['id_role']; ?>
                                                                </td>
								<td width=20%>
									<a href="">
									<?php
									if($name['status']==1){
									?>
                                                                           
                                                                                <a href="<?php echo $action; ?>?id_user=<?php echo $name['id_user']; ?>&id_role=<?php echo $name['id_role']; ?>&s=<?php echo $name['status']; ?>" ><img src="ondot.gif" alt="Activar" align="absmiddle"></a>						<?php
                                                                        }else{
                                                                        ?>
                                                                                <a href="<?php echo $action; ?>?id_user=<?php echo $name['id_user']; ?>&id_role=<?php echo $name['id_role']; ?>&s=<?php echo $name['status']; ?>" ><img src="offdot.gif" alt="Desactivar" align="absmiddle"></a>
                                                                        <?php }?>
								</td>
								
							</tr>
						</table>
                                   	</div>
                                           <?php }}else{ echo "<BR>".$LDNoPermiso;} ?>

					</p>
				</div>

			</div>
			</div>
			</div>
			
		<div style="clear: both;">&nbsp;</div>
		</div>

		<div id="sidebar">
				<ul>
					<li>
						<h2><?php echo $LDCategorias; ?></h2>

						<?php

						include "MenuRbac.php";

						?>
						<script type="text/javascript">

						cssdropdown.startchrome("chromemenu")

						</script>
				</li>
			</ul>
		</div>

		<div style="clear: both;">&nbsp;</div>
	</div>
	</div>
	</div>
</div>

</form>

<?php

include "footer.php";

?>
